#ifndef YUVENCODETHREAD_H
#define YUVENCODETHREAD_H

#include <QThread>
#include <QDebug>
#include <QFile>
#include "yuvfilespec.h"

extern "C"{

    #include <libavcodec/avcodec.h>
}

class YUVEncodeThread : public QThread
{
    Q_OBJECT

public:
    explicit YUVEncodeThread(QObject *parent = nullptr);
    ~YUVEncodeThread();
    void init(YUVFileSpec& yuvFileSpec);

signals:

private:
    QFile* _inYuvFile = nullptr;
    QFile* _outYuvFile = nullptr;
    YUVFileSpec* _yuvFileSpec = nullptr;
    void run();
    bool checkFormat(AVCodec* codec, AVPixelFormat format);
    int yuvEncode(AVCodecContext* codecContext,AVFrame* frame, AVPacket* packet,QFile* outFile);

};

#endif // YUVENCODETHREAD_H
